package com.uzai.console.web.fd;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.common.enums.DeviceTypeEnum;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.device.DeviceGroupQuery;
import com.uzai.console.dto.device.DeviceQuery;
import com.uzai.console.dto.fd.fddeviceplan.FdDevicePlanDto;
import com.uzai.console.dto.fd.fddeviceplan.FdDevicePlanIdDto;
import com.uzai.console.dto.fd.fddeviceplan.FdDevicePlanQuery;
import com.uzai.console.entity.DeviceGroup;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.device.DeviceService;
import com.uzai.console.service.fd.FdDevicePlanService;
import com.uzai.console.vo.base.SelectKeyVo;
import com.uzai.console.vo.device.DeviceInfoVo;
import com.uzai.console.vo.fd.fddeviceplan.FdDevicePlanVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 设备方案
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "设备方案",tags = "个人微信|发单|设备方案")
@ApiSort(103)
@RestController
public class FdDevicePlanController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(FdDevicePlanController.class);

    @Autowired
    private FdDevicePlanService fdDevicePlanService;
    @Autowired
    private DeviceService deviceService;

    @ApiOperation(value = "分页查询发单设备方案列表", notes = "分页查询发单设备方案列表", response = FdDevicePlanVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/fdDevicePlan/findFdDevicePlanList")
    public Object findFdDevicePlanList(@RequestBody FdDevicePlanQuery fdDevicePlanQuery){
        return fdDevicePlanService.findFdDevicePlanList(fdDevicePlanQuery);
    }

    @ApiOperation(value = "分页查询发单设备方案列表", notes = "分页查询发单设备方案列表", response = FdDevicePlanVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/fdDevicePlan/findByPage")
    public Object findFdDevicePlanByPage(@RequestBody FdDevicePlanQuery fdDevicePlanQuery){
        return fdDevicePlanService.findFdDevicePlanByPage(fdDevicePlanQuery);
    }

    @SystemLogType(model = SystemModelEnum.FdDevicePlan, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加发单设备方案", notes = "添加发单设备方案")
    @ApiOperationSupport(order = 2)
    @PostMapping("/fdDevicePlan/addFdDevicePlan")
    public Object addFdDevicePlan(@RequestBody FdDevicePlanDto fdDevicePlanDto){
        fdDevicePlanService.addFdDevicePlan(fdDevicePlanDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.FdDevicePlan, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "编辑发单设备方案", notes = "编辑发单设备方案" )
    @ApiOperationSupport(order = 3)
    @PostMapping("/fdDevicePlan/updateFdDevicePlan")
    public Object updateFdDevicePlan(@RequestBody FdDevicePlanDto fdDevicePlanDto){
        fdDevicePlanService.updateFdDevicePlan(fdDevicePlanDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.FdDevicePlan, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除发单设备方案", notes = "删除发单设备方案")
    @ApiOperationSupport(order = 4)
    @PostMapping("/fdDevicePlan/deleteFdDevicePlan")
    public Object deleteFdDevicePlan(@RequestBody FdDevicePlanIdDto fdDevicePlanIdDto){
        fdDevicePlanService.deleteFdDevicePlan(fdDevicePlanIdDto);
        return true;
    }

    @ApiOperation(value = "查询发单设备方案详情", notes = "查询发单设备方案详情", response = FdDevicePlanVo.class)
    @ApiOperationSupport(order = 5)
    @PostMapping("/fdDevicePlan/findFdDevicePlan")
    public Object findFdDevicePlan(@RequestBody FdDevicePlanIdDto fdDevicePlanIdDto){
        return fdDevicePlanService.findFdDevicePlan(fdDevicePlanIdDto);
    }

    @ApiOperation(value = "查询所有发单设备方案下拉列表", notes = "查询所有发单设备方案下拉列表", response = DeviceInfoVo.class)
    @ApiOperationSupport(order = 6)
    @PostMapping("/fdDevicePlan/findFdDevicePlanListByAll")
    public Object findFdDevicePlanListByAll(){
        FdDevicePlanQuery fdDevicePlanQuery = new FdDevicePlanQuery();
        fdDevicePlanQuery.setMerId(getLoginInfo().getMerId());
        return fdDevicePlanService.findFdDevicePlanListByAll(fdDevicePlanQuery);
    }

    @ApiOperation(value = "查询所有发单设备方案下拉列表", notes = "查询所有发单设备方案下拉列表", response = DeviceInfoVo.class)
    @ApiOperationSupport(order = 6)
    @PostMapping("/fdDevicePlan/findFdDevicePlanListSimple")
    public Object findFdDevicePlanListSimple(){
        FdDevicePlanQuery fdDevicePlanQuery = new FdDevicePlanQuery();
        fdDevicePlanQuery.setMerId(getLoginInfo().getMerId());
        return fdDevicePlanService.findFdDevicePlanListSimple(fdDevicePlanQuery);
    }

    @ApiOperation(value = "查询群内机器人下拉列表", notes = "查询群内机器人下拉列表", response = DeviceInfoVo.class)
    @ApiOperationSupport(order = 7)
    @PostMapping("/fdDevicePlan/findDeviceListByGroup")
    public Object findDeviceListByGroup(@RequestBody DeviceGroupQuery deviceGroupQuery) {
        return deviceService.findDeviceListByGroup(deviceGroupQuery);
    }
}
